package com.arcvideo.acsplayer.utils;

import java.io.File;

public class FileUtil {

	public static void recursionDeleteFile(File file) {
		if (file.isFile()) {
			file.delete();
			return;
		}
		if (file.isDirectory()) {
			File[] childFile = file.listFiles();
			if (childFile == null || childFile.length == 0) {
				file.delete();
				return;
			}
			for (File f : childFile) {
				recursionDeleteFile(f);
			}
			file.delete();
		}
	}

	public static boolean fileIsExist(File file) {
		try {
			if (!file.exists()) {
				return false;
			}
		} catch (Exception e) {
			return false;
		}
		return true;
	}

	public static boolean fileIsExist(String filePath) {
		if (null == filePath || 0 >= filePath.length())
			return false;

		try {
			File file = new File(filePath);
			if (!file.exists()) {
				return false;
			}
		} catch (Exception e) {
			return false;
		}
		return true;
	}
}